package com.example.e.Adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.e.Bean.GoodsBean
import com.example.e.Bean.Order
import com.example.e.R

class OrderHistoryAdapter (val history_order_data:List<Order>):
    RecyclerView.Adapter<OrderHistoryAdapter.OrderHistoryViewHolder>() {

    class OrderHistoryViewHolder(view: View): RecyclerView.ViewHolder(view){
        val tv_order_num: TextView = view.findViewById(R.id.tv_order_num)
        val tv_order_price: TextView = view.findViewById(R.id.tv_order_price)
        
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OrderHistoryViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.elem_order,parent,false)
        return OrderHistoryViewHolder(view)
    }

    override fun onBindViewHolder(holder: OrderHistoryViewHolder, position: Int) {
        if (!history_order_data.isEmpty()) {
            val info = history_order_data[position]
            holder.tv_order_num.text = "${info.order_num}"
            holder.tv_order_price.text = "${info.order_price}"
        }
    }
    override fun getItemCount() = history_order_data.size

}
